import { RequestHeadersAugmentor } from "../apollo/graphql-client";

import { useTokenStore } from "~/modules/auth/store/use-token";

export const createHeadersAugmentor = (): RequestHeadersAugmentor => {
  return (headers) => {
    const token = useTokenStore.getState().token;
    if (token) {
      headers["authorization"] = `Bearer ${token}`;
    }
    return headers;
  };
};
